﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LiveMakkah.Utils;
using LiveMakkah.ViewModels;
using Xamarin.Forms;

namespace LiveMakkah.Pages
{
    public class ChannelPage : BasePage
    {
        private WebView _webView;

        public UrlWebViewSource Source
        {
            get;
            set;
        }
        public ChannelPage()
        {
            _webView = new WebView
            {
                VerticalOptions = LayoutOptions.FillAndExpand
            };
   
            // Accomodate iPhone status bar.
            this.Padding = new Thickness(0, Device.OnPlatform(00, 0, 0), 0, 0);

            // Build the page.
            this.Content = new StackLayout
            {
                Children = 
                {
                    _webView
                }
            };
            Title = "Press Play";
            if (Device.OS == TargetPlatform.Android)
            {
                NavigationPage.SetHasNavigationBar(this, false);
            }
        }

        protected override void OnAppearing()
        {
            base.OnAppearing();
            _webView.SetBinding(WebView.SourceProperty, new Binding("ChannelUrl"));

        }

        protected override void OnDisappearing()
        {
            base.OnDisappearing();
            if (Device.OS == TargetPlatform.Android)
            {
                _webView.SetValue(WebView.SourceProperty, "");
            }

        }


    }
}
